/*package com.calciominoBeta;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;

import com.calciominoBeta.Activity.Main_Activity;
import com.google.android.gcm.GCMRegistrar;
import com.telpoo.frame.net.NetUtils;
import com.telpoo.frame.ui.BaseActivity;
import com.telpoo.frame.utils.Mlog;

import static com.calciominoBeta.GCMIntentService.DISPLAY_MESSAGE_ACTION;
import static com.calciominoBeta.GCMIntentService.EXTRA_MESSAGE;
import static com.calciominoBeta.GCMIntentService.SENDER_ID;

public class InitGCMActivity extends BaseActivity {
	static String TAG = InitGCMActivity.class.getSimpleName();
	AsyncTask<Void, Void, Void> mRegisterTask;
	public static String name;
	public static String email;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		
		setContentView(R.layout.loading);
		
		Mlog.isLog=true;
		String bundle = getIntent().getStringExtra("a");
		Mlog.E("intent=" + bundle);

		// Check if Internet present
		if (!NetUtils.isNetworkAvailable(getBaseContext())) {
			gotoHome();
		}

		// get word of day

		name = "defaultname";
		email = "defaultemail";
		
		AccountManager accMan = AccountManager.get(this);
        Account[] accArray = accMan.getAccountsByType("com.google");
        if(accArray.length>=1)
        	GCMRegistrar.checkDevice(this);
        else gotoHome();
//		try {
//			
//		} catch (Exception e) {
//			Mlog.E(TAG + e);
//			gotoHome();
//		}

		GCMRegistrar.checkManifest(this);

		registerReceiver(mHandleMessageReceiver, new IntentFilter(DISPLAY_MESSAGE_ACTION));

		// Get GCM registration id
		final String regId = GCMRegistrar.getRegistrationId(this);

		// Check if regid already presents
		if (regId.equals("")) {
			// Registration is not present, register now with GCM
			GCMRegistrar.register(this, SENDER_ID);
		} else {
			
			final Context context = this;
			mRegisterTask = new AsyncTask<Void, Void, Void>() {

				@Override
				protected Void doInBackground(Void... params) {
					// Register on our server
					// On server creates a new user
					GCMIntentService.ServerUtilities.register(context, name, email, regId);
					return null;
				}

				@Override
				protected void onPostExecute(Void result) {
					mRegisterTask = null;

					Mlog.I("registration finish. regid=" + regId);
					gotoHome();
				}

			};
			
			
			// Device is already registered on GCM
			if (GCMRegistrar.isRegisteredOnServer(this)) {
				// Skips registration.
				// Toast.makeText(getApplicationContext(),
				// "Already registered with GCM", Toast.LENGTH_LONG).show();
				Mlog.I("// Skips registration. regid=" + regId);
				mRegisterTask.execute(null, null, null);
				gotoHome();

			} else {
				// Try to register again, but not in the UI thread.
				// It's also necessary to cancel the thread onDestroy(),
				// hence the use of AsyncTask instead of a raw thread.
			
				mRegisterTask.execute(null, null, null);
			}
		}
	}
	
	

	private void gotoHome() {
		startActivity(new Intent(getBaseContext(), Main_Activity.class));
		finish();

	}

	*//**
	 * Receiving push messages
	 * *//*
	private final BroadcastReceiver mHandleMessageReceiver = new BroadcastReceiver() {
		@Override
		public void onReceive(Context context, Intent intent) {
			String newMessage = intent.getExtras().getString(EXTRA_MESSAGE);
			// Waking up mobile if it is sleeping
			GCMIntentService.WakeLocker.acquire(getApplicationContext());

			if (newMessage.equalsIgnoreCase(getString(R.string.registed_gcm))) {

				gotoHome();
			}
			// Toast.makeText(getApplicationContext(), "New Message: " +
			// newMessage, Toast.LENGTH_LONG).show();
			Mlog.I("NEW MESSAGE=" + newMessage);

			// Releasing wake lock
			GCMIntentService.WakeLocker.release();
		}
	};

	@Override
	protected void onDestroy() {
		if (mRegisterTask != null) {
			mRegisterTask.cancel(true);
		}
		try {
			unregisterReceiver(mHandleMessageReceiver);
			GCMRegistrar.onDestroy(this);
		} catch (Exception e) {
			Log.e("UnRegister Receiver Error", "> " + e.getMessage());
		}
		super.onDestroy();
	}

	@Override
	protected void onPause() {
		finish();
		super.onPause();
	}

	@Override
	protected void onResume() {
		super.onResume();

	}

}
*/